<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-body">
            <div class="form-unit">基本信息</div>
            <table id="detailInfo"></table>
        </div>
    </div>
</div>
<script>

    $(function(){
        $("#detailInfo").jqGrid({
            url:"<c:url value="/web/admin/enterprise/detailInfo.action?enterpriseId=${enterpriseId}" />",
            datatype: "json",
            autowidth:true,
            height:$(window).width(),
            colNames : ['操作','人员id' ,'（登录账号）手机号','姓名' ],
            colModel : [
                {name: 'operation',align: 'center', formatter: function (cellvalue, options, rowObject) {
                    return '<a  class="btn btn-default btn-xs btnList" onclick="deleteUser(' + rowObject.id + ')" title="删除"><i class="fa fa-pencil"></i>删除</a>&nbsp;';
                    }},
                {name : 'id',index : 'id',width :70,align: "center",sortable: false},
                {name : 'userAccount',index : 'userAccount',width : 150,align: "center",sortable: false},
                {name : 'userName',index : 'userName',width : 100,align: "center" ,sortable: false},

            ],

            ajaxSuccess: function(data){

            }
        });
    })

    // $('#dataGrid').dataGrid({
    //     searchForm: $("#searchForm"),
    //     columnModel: [
    //         {
    //             header: '操作',
    //             name: 'actions',
    //             width: 250,
    //             align: "center",
    //             sortable: false,
    //             title: false,
    //             formatter: function (val, obj, row, act) {
    //                 return ""+
    //                     '<a  class="btn btn-default btn-xs btnList" onclick="editEnterpriseSysUser(' + row.id + ')" title="删除"><i class="fa fa-pencil"></i>删除</a>&nbsp;';
    //             }
    //         },
    //         /*{header: '内部编码', name: 'id', index: 'id', width: 50, align: "center",hidden:"true"},*/
    //         {header: '（登录账号）手机号', name: 'code', index: 'code', width: 100, align: "center"},
    //         {header: '姓名', name: 'code', index: 'code', width: 100, align: "center"},
    //         {header: '创建时间', name: 'createDate', index: 'createDate', width: 100, align: "center"}
    //     ],
    //     // 加载成功后执行事件
    //     ajaxSuccess: function (data) {
    //
    //     }
    // });

    function deleteUser(id) {
        $.ajax({
            type: 'post',
            url: "<c:url value="/web/admin/enterprise/deleteUser.action" />",
            data: {"id": id},
            dataType: 'json',
            async: false,
            success: function (data) {
                js.showMessage(data.msg);
                $("#detailInfo").jqGrid().trigger('reloadGrid');
            },
            error: function () {
                js.showMessage("无法删除此用户");
            }
        });
    }

</script>